package com.ssy.lingxi.member.merchant.handler.validator;

import com.ssy.lingxi.common.constant.manage.ShopTypeEnum;
import com.ssy.lingxi.member.merchant.handler.annotation.MobileShopTypeAnnotation;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import java.util.stream.Stream;

/**
 * App - 商城类型校验注解验证类
 * @author 万宁
 * @version 2.0.0
 * @date 2021-07-17
 */
public class MobileShopTypeValidator implements ConstraintValidator<MobileShopTypeAnnotation, Integer> {
    @Override
    public boolean isValid(Integer value, ConstraintValidatorContext context) {
        if(value == null) {
            return false;
        }

        return Stream.of(ShopTypeEnum.ENTERPRISE, ShopTypeEnum.CHANNEL, ShopTypeEnum.CHANNEL_SELF).anyMatch(e -> e.getCode().equals(value));
    }
}
